<?php

declare(strict_types=1);

namespace App\Model;

use App\Model\RechargeGoods;
use Hyperf\Database\Model\SoftDeletes;
use Hyperf\DbConnection\Model\Model;

class RechargeTemplate extends Model
{
    use SoftDeletes;

    protected ?string $table = 'recharge_template';

    const STATUS_SHOW = 1;
    const STATUS_HIDE = 0;

    public function applet()
    {
        return $this->hasOne(Applet::class, 'id', 'applet_id')->select('id','name');
    }

    public function company()
    {
        return $this->hasOne(Company::class, 'id', 'company_id')->select('id','name');
    }

    public function template()
    {
        return $this->hasMany(RechargeGoods::class, 'recharge_template_id', 'id')
            ->select('recharge_goods.name as name','ml_coin','amount','recharge_goods.status as status','give_coin','recharge_goods.type as type');
    }
}
